#include<bits/stdc++.h>
using namespace std;
#define INF 100010
double solvev1(int v0,int s,int a)
{
    return sqrt((v0*v0)+2*a*s);
}
double solves(int v0,int v1,int a)
{
    return double(((v1*v1)-(v0*v0))/abs(2*a));
}
int n,m,L,V,d[INF],v[INF],a[INF],p[INF];
bool h[INF];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        int cnt=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        memset(h,0,sizeof(h));
        for(int j=1;j<=m;j++)
        {
            cin>>p[j];
            for(int i=1;i<=n;i++)
            {
                if(p[j]<d[i]||h[i]==1)continue;
                if(a[i]<0)
                {
                    if(p[j]>solves(0,v[i],a[i]))continue;
                }
                int v1;
                if(a[i]==0)v1=v[i];
                else v1=solvev1(v[i],p[j]-d[i],a[i]);
                if(v1>V)
                {
                    cnt++;
                    h[i]=1;
                }
            }
        }

        cout<<cnt<<" "<<cnt<<endl;
    }
    return 0;
}
